package com.liudadan.controller;

import com.liudadan.pojo.User;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {
    @PostMapping("register")
    public Object register(@Validated @RequestBody User user,BindingResult bindingResult){

        if (bindingResult.hasErrors()){
            System.out.println("bindingResult:" + bindingResult.getFieldError().getDefaultMessage());
            return "canshuchuruo";
        }
        System.out.println("UserController");
        System.out.println("user:" + user);
        return user;
    }
}
